package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.entity.TalentsLogEntity;
import io.renren.modules.sys.service.TalentsLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-01-04 00:11:35
 */
@RestController
@RequestMapping("sys/talentslog")
public class TalentsLogController extends AbstractController {
    @Autowired
    private TalentsLogService talentsLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = talentsLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        TalentsLogEntity talentsLog = talentsLogService.selectById(id);

        return R.ok().put("talentsLog", talentsLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TalentsLogEntity talentsLog){
    	SysUserEntity sysUserEntity=getUser();
    	talentsLog.setAddDate(new Date());
    	talentsLog.setUserId(sysUserEntity.getUserId().intValue());
    	talentsLog.setUserName(sysUserEntity.getName());
        talentsLogService.insert(talentsLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TalentsLogEntity talentsLog){
        ValidatorUtils.validateEntity(talentsLog);
        talentsLogService.updateAllColumnById(talentsLog);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        talentsLogService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
